

import { toRef } from "vue";
import { useAuthStore } from "@/stores/auth";

/* export function useUserid (){
    let authStore = useAuthStore();
    let auth = authStore.auth;
    console.log("auth",auth);

    return {
        userid:authStore.auth.userid, // userid:是一个死值 => 丧失响应性
    }
} */


export function useUserid (){
    let authStore = useAuthStore();
    let auth = authStore.auth; // store实例中的auth (proxy代理对象)
    // console.log("auth",auth);

    return {
        /* 
            userid:ref({
                value:{
                    get(){
                        return auth.userid
                    },
                    set(newVal){
                       auth.userid = newVal;
                    }
                }
            })
        
        */

        userid:toRef(auth,"userid"), 
    }
}